/**
 * UsuarioBD.java
 */

 /**
 *  AdSec: Administrador de Secundarias
 *  Copyright (C) 2009 Daniela Ramírez Chaves (dannyrch@gmail.com)
 *  Copyright (C) 2009 Leonel Salazar Valverde (leo87sv@gmail.com)
 *
 *  This file is part of AdSec.
 *  AdSec is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  AdSec is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with AdSec.  If not, see <http://www.gnu.org/licenses/>.
 */

package adsec.entidades;

public class UsuarioBD {

    // <editor-fold defaultstate="collapsed" desc="Constantes de Nombres de Columnas">
    public final static String nombreTabla = "usuario_bd";
    public final static String idPerfilNC = "id_perfil";
    public final static String nombreNC = "usuario_bd";
    public final static String passwordNC = "password";
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Atributos privados de la clase">
    private int idPerfil = Perfil.PERFIL_NUEVO;
    private String nombre;
	//Este es el password en texto plano
	private String password;
	//Este es el password en forma de bytes al ser encriptado
	private byte [] passwordEncriptado;
	//Limite de longitud del password en String
	public final static int PASS_MAX_LEN = 40;
	//Limite de longitud del password encriptado
	private final static int ENC_PASS_MAX_LEN = 48;
    // </editor-fold>

    public UsuarioBD(){
		nombre = "";
		password = "";
		passwordEncriptado = null;
    }//fin de constructor

    /**
     * @return the idPerfil
     */
    public int getIdPerfil() {
        return idPerfil;
    }

    /**
     * @param idPerfil the idPerfil to set
     */
    public void setIdPerfil(int idPerfil) {
        this.idPerfil = idPerfil;
    }
    /**
     * @return the nombre
     */
    public String getNombre() {
        return nombre;
    }

    /**
     * @param nombre the nombre to set
     */
    public void setNombre(String nombre) {
		//Restricción debida a MySQL
		if(nombre.length() <= 16){
			this.nombre = nombre;
		}        
    }

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password the password to set
	 * @return true si el password cumple con tener como máximo
	 * PASS_MAX_LEN de longitud, false de lo contrario
	 */
	public boolean setPassword(String password) {
		boolean exito = false;
		if(password.length() <= PASS_MAX_LEN){
			this.password = password;
			exito = true;
		}
		return exito;
	}

	/**
	 * @return the passwordEncriptado
	 */
	public byte[] getPasswordEncriptado() {
		return passwordEncriptado;
	}

	/**
	 * @param passwordEncriptado the passwordEncriptado to set
	 */
	public boolean setPasswordEncriptado(byte[] passwordEncriptado) {
		boolean exito = false;
		if(password.length() <= PASS_MAX_LEN){
			this.passwordEncriptado = passwordEncriptado;
			exito = true;
		}
		return exito;
	}

}//fin de clase Perfil
